package com.qcxy.gzy.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.qcxy.gzy.activity.base.HiddenActivity;
import com.qxcy.gzy.util.SPUtils;

public class FitnessCustomSetActivity extends HiddenActivity implements OnClickListener, OnSeekBarChangeListener{

	private TextView mTargetValue1;
	private TextView mTargetValue2;
	private TextView mTargetValue3;
	
	private int mWeight1 = 10;
	private int mWeight2 = 20;
	private int mWeight3 = 30;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fitness_custom_set);
		
		findViewById(R.id.iv_back).setOnClickListener(this);
		findViewById(R.id.ok).setOnClickListener(this);
		
		mTargetValue1 = (TextView) findViewById(R.id.report_number);
		mTargetValue2 = (TextView) findViewById(R.id.report_time);
		mTargetValue3 = (TextView) findViewById(R.id.report_calorie);
		mTargetValue1.setText("10");
		mTargetValue2.setText("20");
		mTargetValue3.setText("30");
		
		((SeekBar) findViewById(R.id.sb_target1)).setOnSeekBarChangeListener(this);
		((SeekBar) findViewById(R.id.sb_target2)).setOnSeekBarChangeListener(this);
		((SeekBar) findViewById(R.id.sb_target3)).setOnSeekBarChangeListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()){
		case R.id.iv_back: 
			FitnessCustomSetActivity.this.finish();
			break;
		case R.id.ok: 
			SPUtils.setValueSharedFile(FitnessCustomSetActivity.this, "mWeight1", String.valueOf(mWeight1));
			SPUtils.setValueSharedFile(FitnessCustomSetActivity.this, "mWeight2", String.valueOf(mWeight2));
			SPUtils.setValueSharedFile(FitnessCustomSetActivity.this, "mWeight3", String.valueOf(mWeight3));
			FitnessCustomSetActivity.this.finish();
			startActivity(new Intent(FitnessCustomSetActivity.this,FitnessCustomStartActivity.class));
			break;
		}
	}

	@Override
	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
		// TODO Auto-generated method stub
		switch (seekBar.getId()){
		case R.id.sb_target1: 
			mWeight1 = progress;
			mTargetValue1.setText(String.valueOf(progress));
			break;
		case R.id.sb_target2: 
			mWeight2 = progress;
			mTargetValue2.setText(String.valueOf(progress));
			break;
		case R.id.sb_target3: 
			mWeight3 = progress;
			mTargetValue3.setText(String.valueOf(progress));
			break;
		}
	}

	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub
		
	}
}
